package com.education.service.impl;

import com.education.dao.UserMapper;
import com.education.pojo.Img;
import com.education.pojo.TestPaper;
import com.education.pojo.User;
import com.education.service.UserLoginService;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * 邓恒君
 * 个人中心系列功能Service层的实现层
 * Created by Administrator on 2018/4/26.
 */
@Repository
@Service
public class UserLoginServiceImpl implements UserLoginService{
    @Autowired
    private UserMapper userdao;

    @Resource(name="sqlSessionTemplate")
    private SqlSessionTemplate sqlSession;

    @Override
    public int userCount(String username) {
        return userdao.userCount(username);
    }

    @Override
    public User userAnswer(String username) {
        User user = userdao.userAnswer(username);
        return user;
    }

    @Override
    public User userId(String username, String password) {
        User user = userdao.userId(username,password);
        return user;
    }

    @Override
    public int userPasswordA(User user) {
        int i = userdao.userPasswordA(user);
        return i;
    }

    @Override
    public int userPasswordP(Map map) {
        int i = userdao.userPasswordP(map);
        return i;
    }

    @Override
    public int updateUser(User user) {
        int i = userdao.updateUser(user);
        return i;
    }

    @Override
    public int addUser(User user) {
        int i = userdao.addUser(user);
        return i;
    }

    @Override
    public User getUser(int uid) {
        User user = userdao.getUser(uid);
        return user;
    }

    @Override
    public int changeHead(int uid,String uhead) {
        int i = userdao.changeHead(uid,uhead);
        return i;
    }

    @Override
    public User getUserPhone(String username, String password) {
        User phone = userdao.getUserPhone(username,password);
        return phone;
    }

    @Override
    public User getUidPhone(String phone) {
        User user = userdao.getUidPhone(phone);
        return user;
    }

    @Override
    public int getPhoneCount(String phone) {
        int i = userdao.getPhoneCount(phone);
        return i;
    }

    @Override
    public List<TestPaper> getUserCollection(int uid) {
        List<TestPaper> tp = userdao.getUserCollection(uid);
        return tp;
    }

    @Override
    public int deleteUserCollection(int uid, String tpname) {
        int i = userdao.deleteUserCollection(uid,tpname);
        return i;
    }

    @Override
    public int selectUserCollection(String tpName) {
        int i = userdao.selectUserCollection(tpName);
        return i;
    }

    @Override
    public List<Img> getUserImg(int uId) {
        List<Img> list = userdao.getUserImg(uId);
        return list;
    }

    @Override
    public int setUserHead(Img img){
        int i = userdao.setUserHead(img);
        return i;
    }

    @Override
    public int deleteUserHead(int uid, String imgName) {
        int i = userdao.deleteUserHead(uid,imgName);
        return i;
    }
}
